package com.example.carlkaydemo.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @PackageName:com.example.carlkaydemo.config
 * @ClassName:SwaggerConfig
 * @Description:
 * @author:Luan Kay
 * @date 2023/1/6 11:48
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig{
    @Bean
    public Docket api(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.carlkaydemo.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo getApiInfo(){
        Contact contact =new Contact("LK","https://www.xxx.com",
                "1581121799@qq.com");
        return new ApiInfoBuilder()
                .title("栾凯的Demo")
                .version("1")
                .license("Apacje 2.0")
                .licenseUrl("http://wwww.apache.org/licenses/LICENSE-2.0")
                .contact(contact)
                .build();
    }
/*    @Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.oak.mongo.rest.controller"))//扫描的包路径
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("mongo数据库使用接口文档")
                .version("1.0.0")
                .build();
    }*/
}

